<html>
    <head>

    </head>
    <body>
        <p id = "demo"></p>
        <script>
            //第一种方法
            var array = [9,3,6,8,5]
            document.getElementById("demo").innerHTML = array.sort(function(a,b){return a - b});

            //第二种方法
            var arr = [9,3,6,8,5]
            for (i = 0;i < arr.length-1;i++)
            {
                if (arr[i] > arr[i+1])
                    var num = arr[i]
                    arr[i] = arr[i+1]
                    arr[i+1] = num
            }
            document.write(arr)
        </script>
    </body>
</html>